<?php
$userId = Yii::app()->user->id;
?>
<div style="background: #f2f2f4; height: 36px;">
    <span class="update-ribon-right"></span>
    <h1 style="margin-left: 25px; line-height: 36px; text-transform: uppercase;"><?= $object->object_title ?></h1>
</div>
<div style="padding-top: 10px;">
    <?php
    $link = ""; //$object->getObjectLink();
    $imgUrl = Resource::getFullPathByObjectID($object->object_id);
    $image = '  <img width="200" class="' . $object->object_name . '" title="' . $object->object_name . '" alt="' . $object->object_name . '" src="' . $imgUrl . '" style="float:left; border: 1px solid #ccc; margin: 0 5px 5px 0; padding: 2px;">';
    echo CHtml::link($image, $link, array('title' => $object->object_name));
    echo $object->object_content;
    ?>
</div>
<div id="cartContentTest"></div>
<div style="padding: 10px 0;">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'product-detail-form',
        'enableAjaxValidation' => TRUE,
        'enableClientValidation' => FALSE,
        'clientOptions' => array(
            'validateOnChange' => false,
            'validateOnSubmit' => true,
        ),
    ));
    echo $form->hiddenField($model, 'object_id', array('value' => $object->object_id));
    ?>
    So luong: <?php echo $form->textField($model, 'qty', array('value' => 1, 'size' => 3, 'maxlength' => 3, 'class' => 'inputText soluonght')); ?>
    <?php
    if ($userId) {
        echo CHtml::ajaxSubmitButton(
                'Add Cart', array('site/addCart'), array(
            'success' => 'function(data){
                            var output= jQuery.parseJSON(data);
                            $("#cartContentTest").html(output);
                            alert(output.cart+" - "+output.mess);
                            $("#cartContent").html(output.cart);                                        
                            $("#notifyMessage").removeAttr("style").html(output.mess);
                            $("html,body").animate({scrollTop:5},"slow");                                        
                            $("#ajaxLoading").remove();
                        }',
            'beforeSend' => 'function(){                        
                            $("#ajaxLoading").show();
                        }',
                ), array('class' => 'buttonsubmit'));
    }
    ?>
    <?= CHtml::submitButton('Buy now', array('class' => 'buttonsubmit')); ?> 
    <?php $this->endWidget(); ?>

</div>
<?php
$term = ObjectTerm::model()->findByAttributes(array('object_id' => $pid));
$listData = Object::GetObjectRelatedByObjID($pid, 2, 2);
//echo 'term id: '.$term->term_id;
?>
<p style="font-size: 18px;">Product related:</p>
<div class="listproduct" id="id-list-product-gift">
    <?php
    $this->widget('zii.widgets.CListView', array(
        'id' => 'gift' . ConstantDefine::AJAX_BLOCK_SEPERATOR . $this->id . ConstantDefine::AJAX_BLOCK_SEPERATOR . $this->block['block_id'],
        'viewData' => array('asset' => $this->layout_asset),
        'dataProvider' => $listData,
        'itemView' => 'common.blocks.listview.item_product_render',
        'summaryText' => '',
        'ajaxUpdate' => true,
        'pager' => array(
            'header' => '',
            'firstPageLabel' => '&lt;&lt;',
            'prevPageLabel' => '&lt;',
            'nextPageLabel' => '&gt;',
            'lastPageLabel' => '&lt;&lt;',
        ),
    ));
    ?>
</div>


